<?php
class pAdminAction extends pBaseAction{
    public function index(){
        if(array_key_exists('goLink',$_COOKIE)){
            //TODO 对于是否拥有权限跳转到链接须加以检测
            $this->assign('goLink',$_COOKIE['goLink']);
        }
        $this->assign('userVo',$_SESSION[C('USER_AUTH_KEY')]);
        $this->display();
    }

    public function portal(){
        $this->assign('userVo',$_SESSION[C('USER_AUTH_KEY')]);
        $this->display();
    }

    /**
     * 个人设置
     */
    public function setting(){
        $this->assign('userVo',$_SESSION[C('USER_AUTH_KEY')]);
        $this->display();
    }

    public function saveSetting(){
        noCache();
        $editType=$_POST['editype'];
        if($editType=='myinfo' || $editType=='pwd'){        //修改个人信息
            $dao=new UserModel();
            $_POST['account']=$_SESSION[C('USER_AUTH_KEY')]['account'];
            if($dao->updateMyself()){
                echo '{result:"success"}';
            }else{
                echo '{result:"fail",msg:"'.$dao->getError().'"}';
            }
        }
    }
}
